//
//  RadioListSectionTwoCell.m
//  FoodList
//
//  Created by Jason on 16/4/12.
//  Copyright © 2016年 王金晶. All rights reserved.
//

#import "RadioListSectionTwoCell.h"

@implementation RadioListSectionTwoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.coverImag.layer.masksToBounds = YES;
    self.coverImag.layer.cornerRadius = (Height / 8 - 10) / 2;
    
    self.titleLab.font = [UIFont systemFontOfSize:returnFont(Height) + 1];
    self.playCount.font = [UIFont systemFontOfSize:returnFont(Height) - 2];
    self.durationLab.font = [UIFont systemFontOfSize:returnFont(Height) - 2];
    self.creatLab.font = [UIFont systemFontOfSize:returnFont(Height) - 2];
}

- (void)setListModel:(RadioListModel *)listModel {
    _listModel = listModel;
    [self.coverImag sd_setImageWithURL:[NSURL URLWithString:listModel.coverMiddle]];
    self.titleLab.text = listModel.title;
    NSString *temp = [NSString stringWithFormat:@"%@", listModel.playtimes];
    NSInteger tem = [listModel.playtimes integerValue];
    if (temp.length >= 5) {
        self.playCount.text = [NSString stringWithFormat:@"%02ld.%02ld万", tem / 10000, (tem % 10000) / 1000];
    }else {
        self.playCount.text = [NSString stringWithFormat:@"%@", listModel.playtimes];
    }
    NSInteger duration = [listModel.duration integerValue];
    self.durationLab.text = [NSString stringWithFormat:@"%02ld:%02ld", duration / 60, duration % 60];
    
    NSInteger time = [listModel.createdAt integerValue];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:time / 1000];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"YY-MM-dd"];
    NSString *timeStr = [formatter stringFromDate:date];
    self.creatLab.text = [NSString stringWithFormat:@"%@", timeStr];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
